<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
    <meta equiv="X-UA-Compatible" content="chrome=1"> 
    <title>『客易追』-<%= yield :title %></title>
    <link rel="shortcut icon" href="<%= image_path 'logo/favicon.ico' %>" />
    <%= stylesheet_link_tag 'reset','960_24_col','text','application' %>
    <%= stylesheet_link_tag 'jquery-ui-1.8.10.custom' %>
    <%#= stylesheet_link_tag 'demo' %>  
    <%= yield :css %>
    <%= javascript_include_tag 'application' %>
    <%= javascript_include_tag 'autocomplete-rails','jquery.observe_field','jquery.scrollTo','jquery.timers-1.2','jquery.ui.datepicker-zh-CN','jquery.skygqOneDblClick.1.1' %>
    <%= yield :js %>
    <%= csrf_meta_tags %>
    <% if Rails.env.production? %>
    <script type="text/javascript">
      // google analytics
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-5471207-3']);
      _gaq.push(['_setDomainName', 'mytusi.com']);
      _gaq.push(['_trackPageview']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    </script>
    <% end %>
  </head>
  <body>
    <div id="top">
      <div class='container_24'>
        <div class='grid_4 alpha'> 
          <div id="logo">
          	<%#=<div class='en_name'>
          		EasyTrack
          	</div>
          	<div class='cn_name'>
          		客易追
            </div> %>
          </div>
        </div>
        <div id='top_tools' class='grid_8 push_12 omega'>
          <% if has_logined? %>
          <%= link_to "关于我-#{current_user.full_name}",current_user_url(current_user), :title => "关于我-#{current_user.full_name}的基本资料" %>
          <%= link_to "企业",enterprise_url(current_user.enterprise), :title => "所在企业的基本资料" %>
          <%= link_to "员工",users_url, :title => "所有员工、同事" %>
          <%= link_to "分组",groups_url, :title => "所有员工，同事的分组管理" %>
          <%= link_to "注销",session_url(:current), :method => :delete, :title => '退出登录状态' %>
          <% end %>
          <div id='loading_now'>
            <div>读取中...</div>
          </div>
          <%= yield :help %> 
        </div>        
      </div>
      <div class='clear'></div>
    </div>   
    <div id='body'>
      <%= render :file => 'layouts/browser_update.html' if session[:close_browser_remind].nil? and accessed_by?(:browser_version => 'msie 6')  %>
      <div id="middle" class="container_24">
      	<div class='grid_5 alpha omega'>
	      	<div class='grid_5 omega nav_bar'>
	      		<div class='item'>
	      			<%= link_to "最新动态","url", :class => :lastest_news 	%>
	      		</div>
            <div class='item <%= current_controller?(['projects']) ? 'h' : '' %>'>
              <%= link_to "签约项目",projects_url, :class => :my_projects   %>
            </div>
	      		<div class='item <%= current_controller?(['customers']) ? 'h' : '' %>'>
	      			<%= link_to "我的客户", customers_url, :class => :my_customer 	%>
	      		</div>
	      		<div class='item <%= current_controller?(['tasks']) ? 'h' : '' %>'>
	      			<%= link_to "任务清单", tasks_url , :class => :tasks 	%>
	      		</div>
	        </div>	        
	        <script type="text/javascript" charset="utf-8">	        	
	        	$('#middle .item').mouseover(function() {
	        		$('#middle .h').addClass('hh').removeClass('h');
	        	})
	        	$('#middle .item').mouseout(function() {
	        		$('#middle .hh').removeClass('hh').addClass('h');
	        	})
	        </script>
          <% content_for :the_latests  do %>
          <div class="grid_5 recently_viewed alpha omega">
            <div class="head">最近浏览的</div>
            <div class="vieweds grid_5">
              <% BrowsedRecord.limit(10).each do |record| %>
                <% if record.customer.present? %>
                <div class="viewed grid_4">
                  <div class="logo">
                    <%= image_tag "users/#{record.customer.sex}.png", :width => '32', :alt => '联系人', :title => '联系人' %>
                  </div>
                  <div class="info">
                    <div class="name"><%= link_to record.customer.full_name, customer_url(record.customer), :title =>
                    record.customer.full_name, :target => :_blank %></div>
                    <div class="title"><%= link_to truncate(record.customer.title,:length => 10), customer_url(record.customer), :title =>
                    record.customer.title, :target => :_blank %></div>
                  </div>
                </div>
                <% end %>
              <% end %>
            </div>
          </div>
          <% end %>
          <%= content_for?(:under_nav_bar) ? yield(:under_nav_bar) : yield(:the_latests) if has_logined? %>	        
        </div>
        <div class="grid_19 alpha omega">
          <%= yield %>
          <div class='grid_15'>
            <div id="copy_right" class="grid_14 alpha">
              Copyright © 2010-2011 by <b>客易追</b>
              <%= link_to "琼ICP备11000187号-1", 'http://www.miibeian.gov.cn', :target => :_blank, :class => :icp %>
              <% if Rails.env.production? %>
              <%= link_to 'http://wpa.qq.com/msgrd?v=3&uin=7861848&site=qq&menu=yes',
                    :title => '点击这里给我发消息', :class => 'cc' do %>
                <%= image_tag 'http://wpa.qq.com/pa?p=2:7861848:45', :size => '18x18' %> 在线客服                
              <% end %>
              <%= link_to 'http://tongji.baidu.com/web/welcome/ico?s=3c0b7aaf6a4cf8e6bccdeb7394b317a2', :class => 'cc' do %>
              <%= image_tag 'http://tongji.baidu.com/web/image/icon/21.gif?__v=20120229',:target => :_blank, :size => '18x18', :title => '百度统计', :alt => '百度统计' %> 百度统计
              <% end %>
              <% end %>
            </div>
            <div id="tongji" class='grid_1'>
              <% if Rails.env.production? %>
              <div class='tongji hidden'>
                <script type="text/javascript">
                var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
                document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fd7449d70d933199e5c1eb9e531155ae9' type='text/javascript'%3E%3C/script%3E"));
                </script>
              </div>
              <% end %>
            </div>
          </div>
        </div>
        <div class='clear'></div>
      </div>
    </div>
  </body>
  <script type="text/javascript" charset="utf-8">
    function after_page_inited() {
      // console_debug('after_page_inited...');
      // 关闭ff的自动缓存,关闭input回车提交的功能
      $(':text,select,:checkbox,:radio').attr('autocomplete','off');
      // 不使用loading图片
      $('a:not(.no_loading)').bind('ajax:before',function() {
        $(this).replaceWith('<%= loading_image_tag %>');
      });
      // 关闭回车提交
      $(":text[class!='enter_to_submit']").keypress(function(event) {
        if(event.keyCode == 13) {
          // console_debug('enter!  ' + $(this).attr('id') + '  ' + $(this).class)
          return false;
        } 
      });
      $('.item_attr').each(function() {
        // console_debug('init_item_fields :' + $(this).val());   
        var init_attr = function() {
          // console_debug('init item_attr');
          if($(this).is('[placeholder]')) {
            // console_debug($(this).val() + " is 0 ? " + ($(this).val() == 0) )
            if($(this).val() == 0 && $(this).not('.zero_allowed')) {            
              $(this).val('') 
            }
            if($(this).val() == '') {
              $(this).attr('title',$(this).attr('placeholder'))  
            } else {
              $(this).attr('title',$(this).val())
            }          
            // console_debug($(this).attr('title'));
          } 
          // console_debug($(this).attr('placeholder') + '  ' + $(this).attr('error') + '   ' + $(this).is('[error]') )
          if($(this).is('.error')){
            // console_debug('error.............................')
            $(this).attr('title',$(this).attr('error'))  
          }
        }        
        $(this).mouseover(init_attr);
        $(this).mouseover();
      });
      // submit 增加disable_with
      $(":submit[id!='quick_search_order']").attr('data-disable-with','提交中...');
      $(document).ajaxSend(function() {
        if($page_cache['ajax_requests_count'] == null) {
          $page_cache['ajax_requests_count'] = 1;
        } else {
          $page_cache['ajax_requests_count'] += 1;
        }
        $('#loading_now').show();
      });
      $(document).ajaxComplete(function() {
        $page_cache['ajax_requests_count'] -=1;
        if($page_cache['ajax_requests_count'] <=0) {          
          $page_cache['ajax_requests_count'] = 0;
          $('#loading_now').hide();
        }
      });
      // placeholder
      <% if accessed_by?(:browser_version => 'msie') %>
      var placeholder_focus = function() {
        var input = $(this);
        if (input.val() == input.attr('placeholder')) {
          input.val('');
          input.removeClass('placeholder');
        }
      }
      var placeholder_blur = function() {
        var input = $(this);
        if (input.val() == '' || input.val() == input.attr('placeholder')) {
          input.addClass('placeholder');
          input.val(input.attr('placeholder'));
        }
      }
      $('[placeholder]').focus(placeholder_focus).blur(placeholder_blur);
      $('[placeholder]').each(placeholder_blur);
      $('[placeholder]').parents('form').submit(function() {
        $(this).find('[placeholder]').each(function() {
          var input = $(this);
          if (input.val() == input.attr('placeholder')) {
            input.val('');
          }
        })
      });
      <% end %>
    }
    
    $(function() {
      after_page_inited();      
      $(document).ajaxComplete(function() {
        after_page_inited();
      });
      // autocomplete
      $('.text_field_autocomplete').bind( "input.autocomplete", function(){ 
        $(this).trigger('keydown.autocomplete'); 
      });  
    })
  </script> 
</html>